package com.example.trackcircuitdiagnosis.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.example.trackcircuitdiagnosis.entity.UserEntity;
import com.example.trackcircuitdiagnosis.exception.HttpException;
import com.example.trackcircuitdiagnosis.exception.HttpResult;
import com.example.trackcircuitdiagnosis.exception.HttpResultGenerator;
import com.example.trackcircuitdiagnosis.exception.HttpStatusEnum;
import com.example.trackcircuitdiagnosis.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/user")
public class LoginController {
    @Autowired
    private UserService userService;
    @PostMapping(value="/login")
    @Operation(description = "登录")
    public HttpResult login(UserEntity user) throws JSONException {
        return userService.login(user);

    }

    @PostMapping(value="/logout")
    @Operation(description = "注销登录")
    public HttpResult logout(HttpServletRequest request) throws JSONException {
        return userService.logout(request);

    }
}
